package com.xb.p4_widgets;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.ImageView;

public class ImageViewActivity extends AppCompatActivity {

    ImageView ting_image;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_view);

        ting_image=findViewById(R.id.ting_image);
    }

    public void centercrop(View view){
        ting_image.setScaleType(ImageView.ScaleType.CENTER_CROP);
    }

    public void centerinside(View view){
        ting_image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    }



    public void fit_center(View view){
        ting_image.setScaleType(ImageView.ScaleType.FIT_CENTER);
    }

    public void fit_end(View view){
        ting_image.setScaleType(ImageView.ScaleType.FIT_END);
    }

    public void fit_start(View view){
        ting_image.setScaleType(ImageView.ScaleType.FIT_START);
    }

    //不保持纵横比，拉伸图片填充区域
    public void fit_xy(View view){
        ting_image.setScaleType(ImageView.ScaleType.FIT_XY);
    }

    //保持原生大小
    public void matrix(View view){
        ting_image.setScaleType(ImageView.ScaleType.MATRIX);
    }
    
}
